package me.zhengjie.modules.system.domain;

import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import me.zhengjie.base.BaseEntity;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.sql.Date;
import java.util.Objects;

/**
 * 需求表
 *
 * @author guoyuan
 * @version 1.0.0
 * @since 1.0.0
 */
@Entity
@Getter
@Setter
@Table(name = "st_requirement")
public class Requirement extends BaseEntity implements Serializable {

    @Id
    @NotNull(groups = Update.class)
    @ApiModelProperty(value = "ID", hidden = true)
    @GeneratedValue(generator = "requirement_uuid")
    @GenericGenerator(name = "requirement_uuid", strategy = "uuid")
    @Column(name = "id", length = 32, unique = true, nullable = false)
    private String id;

    @NotNull
    @ApiModelProperty(value = "需求编号")
    private Integer requirementId;

    @NotBlank
    @ApiModelProperty(value = "需求主题")
    private String requirementTheme;

    @NotNull
    @ManyToOne
    @JoinColumn(name = "system_id", referencedColumnName = "id")
    @ApiModelProperty(value = "所属系统id")
    private System system;

    @ApiModelProperty(value = "需求描述")
    private String requirementDesc;

    @NotBlank
    @ApiModelProperty(value = "状态：待计划、案例编写中、待评审测试报告、待添加到投产清单、待验证、已验证、已投产")
    private String status;

    @ApiModelProperty(value = "计划上线时间")
    private Date planDate;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Requirement that = (Requirement) o;
        return Objects.equals(id, that.id) &&
                Objects.equals(requirementId, that.requirementId) &&
                Objects.equals(requirementTheme, that.requirementTheme) &&
                Objects.equals(system, that.system) &&
                Objects.equals(requirementDesc, that.requirementDesc) &&
                Objects.equals(status, that.status) &&
                Objects.equals(planDate, that.planDate);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, requirementId, requirementTheme, system, requirementDesc, status, planDate);
    }
}
